Separating the Trackbacks from Comments
For those who always leave their comments, I believe most of you know the differences between trackbacks and comments. For starters, trackbacks is a way to notify a website when you publish an entry that references it.
…With pingback and trackback, blogs are interconnected. Think of them as the equivalents of acknowledgments and references at the end of an academic paper, or a chapter in a textbook.
- source: WordPress Codex
By default, when you send a trackback, a link with a short excerpt of your entry will appear on the referenced website which looks similar like this:

What do you think? Honestly, it doesn’t look professional at all. Plus, it encumbers your readers in following the conversation established in the comments section. Why don’t you separate them? Not only it creates a nice, clean look, but also doesn’t break up the flow of reader comments.
It is fairly easy to achieve. All it needs is some tweaks on the comments.php file. Caution! Always backup your files.
First, you need to find this loop in your comments.php’s template. The location varies depending on the theme you used.
<?php foreach ($comments as $comment) : ?>
When you find it, insert these codes below immediately AFTER the above loop.
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
This is how it supposes to look:
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
Done? Let’s move on to second step. Find this loop by scrolling down.
<?php endforeach; /* end for each comment */ ?>
When you find it, insert these codes immediately BEFORE the above code in order to close the execution of it.
<?php } else { $trackback = true; } ?>
This is how it supposes to look:
<?php } else { $trackback = true; } ?>
<?php endforeach; /* end for each comment */ ?>
Your list of comments will continue to display as normal, but without any trackbacks or pingbacks. Now we need to create second comments loop for the trackbacks. Scroll down a bit and you will find this code:
<?php else : // this is displayed if ... so far ?>
Insert this code BEFORE the above code:
<?php if ($trackback == true) { ?>
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
<?php } ?>
There you go. A complete tutorial to separate the tackbacks from comments. This is how the final codes should look:
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
//
//
<?php } else { $trackback = true; } ?>
<?php endforeach; /* end for each comment */ ?>
//
//
<?php if ($trackback == true) { ?>
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
<?php } ?>
<?php else : // this is displayed if ... so far ?>
You can use <ol> instead of <ul>, or modify the title according to your requirements. It is recommended to separate your comments and trackbacks as it’s proven to be useful.
Related entries
Share your thoughts
